package leetcode_2501_2600;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class LeeCode_2501 {
    public static void main(String[] args) {

    }
    private static int longestSquareStreak(int[] nums) {
        Set<Long> set = new HashSet<>();
        for (int num : nums) {
            set.add((long) num);
        }
        int ans = -1;
        Arrays.sort(nums);
        Set<Long> used = new HashSet<>();
        for (int num : nums) {
            if (used.contains((long)num))
                continue;
            int count = 0;
            long t = num;
            while (set.contains(t)){
                used.add(t);
                count++;
                t *= t;
            }
            if (count >= 2){
                ans = Math.max(ans, count);
            }
        }
        return ans;
    }
}
